# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: schuay <jakob.gruber@gmail.com>
# Contributor: Mike Sampson <mike at sambodata dot com>
# Contributor: Adrian Stratulat <adrian.stratulat at inboxcom>
# Contributor: Anton Bazhenov <anton.bazhenov at gmail>
# Contributor: KillaB <xGenoBlast@gmail.com>
# Contributor: Callan Barrett <wizzomafizzo@gmail.com>
# Contributor: Christian Schmidt <xmucknertx@googlemail.com>
# Contributor: Sebastian Sareyko <public@nooms.de>

pkgname=angband
pkgver=4.2.5
pkgrel=2
pkgdesc='A roguelike dungeon exploration game based on the writings of JRR Tolkien'
arch=('loong64' 'x86_64')
url='https://rephial.org/'
license=('GPL2' 'custom')
depends=(
  'glibc'
  'sdl2'
  'sdl2_ttf'
  'sdl2_image'
  'sdl2_mixer'
  'ncurses'
  'xorg-fonts-misc'
  'xorg-mkfontscale'
  'hicolor-icon-theme'
  'libx11'
)
makedepends=('git' 'python-docutils')
_commit='69e24dbb001818d5f902215e7a474d122e12202c'
source=(
  "$pkgname::git+https://github.com/angband/angband#commit=$_commit"
  'remove-dirty-version.patch'
)
b2sums=('SKIP'
        '84e2a3f0a959072167aaf55718e02643d0b5793da18bc60d5464de0477fe9237e5f6e3374ee0919ca7079fb86a65c011db979e7d9dbe052af8caa883bf16e906')

pkgver() {
  cd "$pkgname"

  git describe --tags | sed 's/^v//'
}

build() {
  cd "$pkgname"

  # contrary to popular belief, arch linux is *not* dirty.
  patch -p1 -i "$srcdir/remove-dirty-version.patch"

  ./autogen.sh

  ./configure \
    --prefix=/usr \
    --bindir=/usr/bin \
    --sysconfdir=/usr/share/angband \
    --enable-sdl2 \
    --enable-sdl2-mixer

  make
}

package() {
  cd "$pkgname"

  make DESTDIR="$pkgdir" install

  # license
  install -vDm644 docs/copying.rst "$pkgdir/usr/share/licenses/$pkgname/COPYING"
}
